package com.dream.technology.components.riskControl.container;

import com.dream.technology.db.entity.RcOperationalSymbol;
import com.dream.technology.service.RcOperationalSymbolService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 描述：
 *
 * @author chen_q_i@163.com
 * 2018/12/6 : 14:35.
 * @version : 1.0
 */
@Slf4j
@Component("symbolContainer")
public class SymbolContainer {

    @Autowired
    private RcOperationalSymbolService rcOperationalSymbolService;

    @Bean(name = "symbolMap")
    public Map<String,RcOperationalSymbol> symbolMap(){
        List<RcOperationalSymbol> rcOperationalSymbols = rcOperationalSymbolService.selectAll();
        Map<String,RcOperationalSymbol> map = new HashMap<>(rcOperationalSymbols.size()<<1);
        rcOperationalSymbols.forEach(symbolMap->{
            map.put(symbolMap.getCode(),symbolMap);
        });
        return map;
    }


}
